<?php
 
echo date("Y-m-d H:i:s")."<br />";
echo date("Y-m-d h:i:s")."<br />";;  
$postNo = explode(',',"101,102,103,104,266"); //逗号分隔运单号
foreach ($postNo as $mailNo) {
    if (!empty($mailNo)) {
        /*$batchData[] = array(
            'orderNo'     => $batch['OrderNo'],
            'mailNo'      => $mailNo,
            //'expressCode' => $express['code'],
            'expressName' => $express['name'],
        );*/
        echo "SSS=".$mailNo."<br>";
    }
}

if(strpos('中华人民共和国','人民') !== false){ 
 echo '包含人民'; 
}else{
 echo '不包含人民'; 
}
echo "<br>";
$code_name = "韵达";
//增速海淘 韵达国际 圆通国际 这三家物流公司没有，code返回other
$arr =array("顺丰速运|shunfeng","申通快递|shentong","韵达快递,韵达速递|yunda","斑马物流|banma","中通国际|zhongtongguoji");
foreach ($arr as $key => $val) {
        $result = '';
   if(strpos($val,$code_name) !== false){ 
        $result = $val;
        break;
    }
}
if ($result =='')
$result =$code_name."|other";

echo "result=".$result;
$arr_stock = "0,1,2,3,4,5,6";
$goods = explode(',', $arr_stock);
$stocks = '';
foreach ($goods as $key=>$val) {
   # if ($val == '' || $val < 0) $make_stock = 0;
    $stocks .= strlen($stocks)==0  ? $val : ',' . $val;
     
   // $erpCodes .= empty($erpCodes) ? $val['erpCode'] : ',' . $val['erpCode'];
}
echo "stock_string=".$stocks;
 

 

function array2XML($obj, $array)
{
    foreach ($array as $key => $value)
    {
        if(is_numeric($key))
            $key = 'item' . $key;

        if (is_array($value))
        {
            $node = $obj->addChild($key);
            array2XML($node, $value);
        }
        else
        {
            $obj->addChild($key, htmlspecialchars($value));
        }
    }
}

// define php multi-dimensional array
$my_array = array (
    '0' => array (
        'id' => 'XYZ100',
        'personal' => array (
            'name' =>'Ashton Cox',
            'gender' => 'Male',
            'age' => 32,
            'address' => array (
                 'street' => '7 24th Street',
                 'city' => 'New York',
                 'state' => 'NY',
                 'zipcode' => '10038'
             )
        ),
        'profile' => array (
            'position' => 'Team Lead',
            'department' => 'Software'
        )
    ),
    '1' => array (
        'id' => 'XYZ121',
        'personal' => array (
            'name' => 'Rhona Davidson',
            'gender' => 'Female',
            'age' => 40,
            'address' => array (
                 'street' => 'S2 115th Street',
                 'city' => 'New York',
                 'state' => 'NY',
                 'zipcode' => '10100'
             )
        ),
        'profile' => array (
            'position' => 'Integration Specialist',
            'department' => 'Operations'
        )
    )
);
$xml = new SimpleXMLElement('<root/>');

// function callback
 array2XML($xml, $my_array);

var_dump($abc);
// save as xml file
echo (($xml->asXML('data.xml')) ? 'Your XML file has been generated successfully!' : 'Error generating XML file!');
?>